package com.xuecheng.media.controller;

import com.xuecheng.base.result.RestResponse;
import com.xuecheng.media.service.IMediaOpenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 勾新杰
 * @version 1.0
 * @description: 媒资公开查询接口
 * @date 2025/2/14 20:45
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/open")
@Api(tags = "媒资公开查询接口")
public class MediaOpenController {

    /**
     * 媒资公开查询接口
     */
    private final IMediaOpenService mediaOpenService;

    /**
     * 根据文件id查询文件的访问url
     * @param mediaId 文件id
     * @return 文件的访问url
     */
    @GetMapping("/preview/{mediaId}")
    @ApiOperation("预览文件")
    public RestResponse<String> getUrlByMediaId(@PathVariable String mediaId){
        String url = mediaOpenService.getUrlByMediaId(mediaId);
        return RestResponse.success(url);
    }
}
